package com.qf.controller;

import com.qf.dto.R;
import com.qf.pojo.Category;
import com.qf.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/category")
public class CategoryController {
    private CategoryService categoryService;

    @Autowired
    public void setCategoryService(CategoryService categoryService) {
        this.categoryService = categoryService;
    }
    @PostMapping("/newcategory/{categoryName}")
    public R addCategory(@PathVariable String categoryName){
        categoryService.addcategory(categoryName);
        return R.setOk(null);
    }

    @GetMapping("/categories")
    public R getAllCategoryIsTrue(){
        List<Category> categoryList=categoryService.findAllCategory();
        return R.setOk(categoryList);
    }


}
